package com.dc.business.datacollectbusiness.config;

import com.dc.business.datacollectbusiness.service.HJ212ReceiverService;
import com.dc.business.datacollectbusiness.service.publicInstitutionService;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.io.IOException;


// 自启动配置类
@Component
@PropertySource("classpath:EnergyEfficientSystem.properties")
@PropertySource("classpath:OperationalPower.properties")
@EnableScheduling
@Slf4j
public class StartupInitializer {

    @Autowired
    private HJ212ReceiverService hj212ReceiverService;

    @Autowired
    private publicInstitutionService publicInstitutionService;


    @Scheduled(cron = "${powerSchedule.cron}")
    public void performTaskWithCron1() throws InterruptedException, IOException {
        log.info("开始检测工况用电数据可视化----------------------------");
        hj212ReceiverService.collectHJ212Msg();
    }

    @Scheduled(cron = "${schedule.cron}")
    public void performTaskWithCron2() throws IOException {
        // 定时任务的内容
        log.info("执行定时远端调用任务: " + publicInstitutionService.sendDataToStorageMap());
    }

}